<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "实名认证");
%>

<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>

<style>

	.weui-cells {
		font-size: 0.7rem;
	}
	.weui-cell:before{
		border-top:0;
	}
	.weui-cells:after {
		border-bottom: 0;
	}
	.weui-cells:before {
		border-top: 0;
	}	
	.weui-cell{
		padding:10px 0px 10px 0px;
		margin:0 auto;
		width:85%;
	}		
	.weui-label {
		letter-spacing: 0.2rem;
		width: 110px;
		color: #27a0ff;
	}	
	.weui-btn_primary {
		width: 90%;
		background-color: #27a0ff;
	}	

	.spacing {
		width:100%;
		height:10px;
		background-color: #ebebeb;
		margin: 10px 0px;
	}

</style>

<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>
<div class="goback" data-back-href="<c:url value='/wechat/cust/personCenter/personDetailed'/>"></div>

<form class="formRealName" method="post">
<div class="weui-cells weui-cells_form">
	<div class="weui-cell">
		<div class="weui-cell__hd"><label class="weui-label">真实姓名</label></div>
		<div class="weui-cell__bd">
			<input id="username" name="custRealName" class="weui-input" type="text" placeholder="请输入姓名" value="">
		</div>
	</div>	
	<div class="weui-cell">
		<div class="weui-cell__hd">
			<label class="weui-label">身份证号</label>
		</div>
		<div class="weui-cell__bd">
			<input id="idCode" name="custIDCard" class="weui-input"  placeholder="请输入身份证号" value="">
		</div>
	</div>
</div>
<div class="spacing"></div>

<button type="button" onclick="toRealName()" class="weui-btn weui-btn_primary" style="width: 90%;">提交</button>
</form>
<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>	
<script src="<c:url value='/plugins/jqweui/js/city-picker.min.js'/>" type="text/javascript"></script>
<script>

	function toRealName(){	
		if(!checkInput()){return;};
		var url =$.getVirtualPath()+'/wechat/cust/personCenter/torealName';
		$.post(url,$(".formRealName").serialize(),function(res){
			if(res=="true"){
				$.toast("认证成功");
				 setTimeout(function(){//两秒后跳转  
                     window.location.href=$.getVirtualPath()+"/wechat/cust/personCenter/personDetailed";
                  },3000);  
				
			}else if(res=="false"){
				$.toast("认证失败,请重新填写", "forbidden");
			}
		});
	}

	//验证姓名
	function checkUsername(){
		var name = $("#username").val();
		if($.isNull(name)){
			$.toptip('真实姓名不能为空','error');
			return false;
		}
		return true;
	}
	
	/*验证身份证*/
	function checkidCode(){
		var idCode = $('#idCode').val();
		var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		if($.isNull(idCode)) {
			$.toptip("请输入身份证号",'error');
			return false;
		}else if(!pattern.test(idCode)){
			$.toptip('请输入正确的身份证号','error');
			return false;
		}
		return true;
	}
	
	//检查输入
	function checkInput(){
		if(checkUsername()&&
			checkidCode()){
			return true;
		}
		return false;
	}
		
</script>

<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/tools/upload-cos.jsp"%>

